package com.sky.controller.user;

import com.sky.dto.ShoppingCartDTO;
import com.sky.result.Result;
import com.sky.service.UserService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/shoppingCart")
public class ShoppingCartController {
    @Autowired
    private UserService userService;


    @PostMapping("/add")
    public Result addShoppingCart(@RequestBody ShoppingCartDTO shoppingCartDTO){
        userService.addShoppingCart(shoppingCartDTO);
        return Result.success();
    }
    @DeleteMapping("/clean")
    public Result clean(){
        userService.cleanShoppingCart();
        return Result.success();
    }
    @GetMapping("/list")
    public Result getshoppingCartList(){

        return Result.success(userService.getshoppingCartList());
    }
    @PostMapping("/sub")
    public Result deleteShoppingCart(@RequestBody ShoppingCartDTO shoppingCartDTO){
        userService.deleteShoppingCart(shoppingCartDTO);
        return Result.success();
    }
 }

